home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / UPC12BS1.ZIP / UUCICO / COMM.ASM < prev    next >
Assembly Source File  |  1993-05-30  |  52KB  |  1,663 lines

  1.     TITLE    COMM
  2.     PAGE    83,132
  3. ;    $Id: comm.asm 1.7 1993/05/31 01:39:23 ahd Exp $
  4. ;
  5. ;    $Log: comm.asm $
  6. ;; Revision 1.7  1993/05/31  01:39:23  ahd
  7. ;; Add return to spin loop (fix by Bill Plummer)
  8. ;; Drop FIFO size to 8
  9. ;;
  10. ;; Revision 1.4  1993/05/30  00:20:02  ahd
  11. ;; Insert minor delay to allow slow modems to catch up
  12. ;;
  13. ;; Revision 1.2  1992/12/18  12:08:25  ahd
  14. ;; Add Plummer's fix for bad TASM assemble of com_errors
  15. ;;
  16. ;
  17. ; 14-Jun-93 plummer    Add RET to spinloop routine
  18. ; 14-Jun-93 plummer    Set FIFO thresholds to 8 rather than 16 bytes
  19. ; 18-May-93 plummer    Define IO$DELAY and use in UART type determination
  20. ; 16-May-93 plummer    Debug code to printout UART type
  21. ; 22-Apr-93 plummer    Make case consistent in "TBuff" so it links properly
  22. ;  2-Dec-92 plummer    Fix com_errors() again.  Change got lost.
  23. ; Fix com_errors() to avoid problems with tasm.  Plummer, 11/16/92
  24. ; 8259 EOI issued after interrupts serviced.  Plummer, 3/25/92
  25. ; Fix botch in Set_Baud.  Plummer, 3/20/92
  26. ; Put in Gordon Lee's cure from dropped interrupts.  Plummer, 3/19/92
  27. ; TEMPORARY ioctl_com().  Plummer, 3/9/92.
  28. ; Clear OUT2 bit in UART.  Some machines use it so enable IRQ. Plummer, 3/9/92
  29. ; Release send buffer if we can't assign a recv buffer.  Plummer, 3/9/92
  30. ; Move EQU's outside of SP_TAB struc definition.  ahd, 3/8/92.
  31. ; ahd changes: short jmp's out of range in INST, OPEN ???  (ahd, 3/?/92)
  32. ; open_com() leaves DTR unchanged so Drew's autobaud works.  Plummer, 3/2/92
  33. ; Missing DX load in close_com() -- FIFO mode not cleared.  Plummer, 3/2/92
  34. ; C calling convention does not require saving AX, BX, CX, DX. Plummer 2/23/92
  35. ; Flush consideration of the PC Jr.  Wm. W. Plummer, 2/15/92
  36. ; Cleanup PUSHF/POPF and CLI/STI useage.  Wm. W. Plummer, 2/15/92
  37. ; Make SENDII have Giles Todd's change.  Wm. W. Plummer, 2/15/92
  38. ; Changes to Giles Todd's code to support dynamic buffers.  Plummer, 2/3/92
  39. ; 26 Jan 92 Giles Todd    Prime THR for UARTs which do not give a Tx empty
  40. ;            interrupt when Tx interrupts are enabled.
  41. ; S_SIZE & R_SIZE may be set with -D to MASM.  Wm. W. Plummer, 1/19/92
  42. ; Assign buffers dynamically.  Wm. W. Plummer, 1/19/92
  43. ; Unfix byte length -- I screwed up.  Wm. W. Plummer, 1/15/92
  44. ; Fix byte length with specific PARITY select.    Wm. W. Plummer, 1/13/92
  45. ; Buffers up to 4096 per AHD.  Wm. W. Plummer, 1/1/92
  46. ; Always use FIFO length of 16 on send side.  Wm. W. Plummer, 12/30/91.
  47. ; Init DSR and CTS previous state from current status.    Wm. Plummer, 12/30/91.
  48. ; UUPC conditional to disable v.24.  Wm. W. Plummer, 12/30/91.
  49. ; Buffer sizes up to 2048 per ahd.  Wm. W. Plummer, 12/15/91.
  50. ; dtr_on() switches to D connection if CTS&DSR don't come up.  WWP, 12/15/91.
  51. ; New dtr_on() logic.  Wm. W. Plummer, 12/11/91
  52. ; Fix bad reg. per report from user.  Wm. W. Plummer, 12/11/91
  53. ; Semicolon before control-L's for MASM 5.00 per ahd. Wm. W. Plummer, 12/8/91
  54. ; Use AHD's handling of COM ports.  Wm. W. Plummer, 11/29/91
  55. ; Buffer sizes reduced and required to be 2**N.  Wm. W. Plummer, 11/11/91
  56. ; Accomodate V.24 requirements on DTR flaps.  Wm. W. Plummer 10/15/91
  57. ; Revised DTR_ON_COM to solve user problem.  Wm. W. Plummer, 10/3/91
  58. ; Make time delays independent of CPU speed.  Wm. W. Plummer, 9/16/91
  59. ; Use interrupts to trace CD, DSR, Wm. W. Plummer, 9/16/91
  60. ; Remove modem control from TXI. Wm. W. Plummer, 9/13/91
  61. ; Completely redo the XOFF/XON logic.  Too many races before. Wm. W. Plummer
  62. ; Revise interrupt dispatch for speed & function.  William W. Plummer, 9/12/91
  63. ; Merge in ahd's changes to flush control Q,S when received as flow control
  64. ; SEND buffer allows one byte for a SENDII call.  Avoids flow control
  65. ;  lockups. - William W. Plummer, 8/30/91
  66. ; Support for NS16550A chip with SILO - William W. Plummer, 8/30/91
  67. ; Add modem_status() routine - William W. Plummer, 7/2/91
  68. ; Put wrong code under AHD conditional - William W. Plummer, 7/2/91
  69. ; Change TITLE, repair bad instr after INST3 - William W. Plummer, 7/1/91
  70. ; Modified to use COM1 thru COM4 - William W. Plummer, 2/21/91
  71. ; Eliminate (incomplete) support for DOS1 - William W. Plummer, 11/13/90
  72.  
  73. ; Changes may be copied and modified with no notice.  Copyrights and copylefts
  74. ; are consider silly and do not apply.    --  William W. Plummer
  75.  
  76. ; modified to use MSC calling sequence.  jrr 3/86
  77. ;****************************************************************************
  78. ; Communications Package for the IBM PC, XT, AT and strict compatibles.
  79. ; May be copied and used freely -- This is a public domain program
  80. ; Developed by Richard Gillmann, John Romkey, Jerry Saltzer,
  81. ; Craig Milo Rogers, Dave Mitton and Larry Afrin.
  82. ;
  83. ; We'd sure like to see any improvements you might make.
  84. ; Please send all comments and queries about this package
  85. ; to GILLMANN@USC-ISIB.ARPA
  86. ;
  87. ; o Supports both serial ports simultaneously
  88. ; o All speeds to 19200 baud
  89. ; o Compatible with PC, XT, AT
  90. ; o Built in XON/XOFF flow control option
  91. ; o C language calling conventions
  92. ; o Logs all comm errors
  93. ; o Direct connect or modem protocol
  94.     PAGE;
  95. ;
  96. ; Buffer sizes -- *** MUST be powers of 2 ****
  97.  
  98. IFDEF UUPC
  99.     R_SIZE    EQU    4096
  100.     S_SIZE    EQU    4096
  101. ENDIF
  102.  
  103. ; If not set above, maybe on assembler command line.  But if not, ...
  104. IFNDEF R_SIZE
  105.     R_SIZE    EQU    512    ; Recv buffer size
  106. ENDIF
  107. IFNDEF S_SIZE
  108.     S_SIZE    EQU    512    ; Send buffer size
  109. ENDIF
  110.  
  111. ; INTERRUPT NUMBERS
  112. INT_COM1 EQU    0CH        ; COM1: FROM 8259
  113. INT_COM2 EQU    0BH        ; COM2: FROM 8259
  114. INT_COM3 EQU    0CH        ; COM3: FROM 8259
  115. INT_COM4 EQU    0BH        ; COM4: FROM 8259
  116. ; 8259 PORTS
  117. INTA00    EQU    20H        ; 8259A PORT, A0 = 0
  118. INTA01    EQU    21H        ; 8259A PORT, A0 = 1
  119. ; COM1: & COM3: LEVEL 4
  120. IRQ4    EQU    2*2*2*2     ; 8259A OCW1 MASK, M4=1, A0=0
  121. NIRQ4    EQU    NOT IRQ4 AND 0FFH ; COMPLEMENT OF ABOVE
  122. EOI4    EQU    4 OR 01100000B    ; 8259A OCW2 SPECIFIC IRQ4 EOI, A0=0
  123. ; COM2: & COM4: LEVEL 3
  124. IRQ3    EQU    2*2*2        ; 8259A OCW1 MASK, M3=1, A0=0
  125. NIRQ3    EQU    NOT IRQ3 AND 0FFH ; COMPLEMENT OF ABOVE
  126. EOI3    EQU    3 OR 01100000B    ; 8259A OCW2 SPECIFIC IRQ3 EOI, A0=0
  127.  
  128. ; FLOW CONTROL CHARACTERS
  129. CONTROL_Q EQU    11H        ; XON
  130. CONTROL_S EQU    13H        ; XOFF
  131. ; MISC.
  132. DOS    EQU    21H        ; DOS FUNCTION CALLS
  133.  
  134. ;
  135. ; ROM BIOS Data Area
  136. ;
  137. RBDA    SEGMENT AT 40H
  138. RS232_BASE DW    4 DUP(?)    ; ADDRESSES OF RS232 ADAPTERS
  139. RBDA    ENDS
  140.  
  141. PAGE;
  142. ;
  143. ; TABLE FOR EACH SERIAL PORT
  144. ;
  145. SP_TAB        STRUC
  146. PORT        DB    ?    ; 1 OR 2 OR 3 OR 4
  147. ; PARAMETERS FOR THIS INTERRUPT LEVEL
  148. INT_COM     DB    ?    ; INTERRUPT NUMBER
  149. IRQ        DB    ?    ; 8259A OCW1 MASK
  150. NIRQ        DB    ?    ; COMPLEMENT OF ABOVE
  151. EOI        DB    ?    ; 8259A OCW2 SPECIFIC END OF INTERRUPT
  152. ; INTERRUPT HANDLERS FOR THIS LEVEL
  153. INT_HNDLR    DW    ?    ; OFFSET TO INTERRUPT HANDLER
  154. OLD_COM_OFF    DW    ?    ; OLD HANDLER'S OFFSET
  155. OLD_COM_SEG    DW    ?    ; OLD HANDLER'S SEGMENT
  156. ; ATTRIBUTES
  157. INSTALLED    DB    ?    ; IS PORT INSTALLED ON THIS PC? (1=YES,0=NO)
  158. BAUD_RATE    DW    ?    ; 19200 MAX
  159. CONNECTION    DB    ?    ; M(ODEM), D(IRECT)
  160. PARITY        DB    ?    ; N(ONE), O(DD), E(VEN), S(PACE), M(ARK)
  161. STOP_BITS    DB    ?    ; 1, 2
  162. XON_XOFF    DB    ?    ; E(NABLED), D(ISABLED)
  163. ; FLOW CONTROL STATE
  164. HOST_OFF    DB    ?    ; HOST XOFF'ED (1=YES,0=NO)
  165. PC_OFF        DB    ?    ; PC XOFF'ED (1=YES,0=NO)
  166. URGENT_SEND    DB    ?    ; We MUST send one byte (XON/XOFF)
  167. SEND_OK     DB    ?    ; DSR and CTS are ON
  168. ; ERROR COUNTS
  169. ERROR_BLOCK    DW    8 DUP(?); EIGHT ERROR COUNTERS
  170.  
  171. ; UART PORTS - DATREG thru MSR must be in order shown.
  172. DATREG        DW    ?    ; DATA REGISTER
  173. IER        DW    ?    ; INTERRUPT ENABLE REGISTER
  174. IIR        DW    ?    ; INTERRUPT IDENTIFICATION REGISTER (RO)
  175. LCR        DW    ?    ; LINE CONTROL REGISTER
  176. MCR        DW    ?    ; MODEM CONTROL REGISTER
  177. LSR        DW    ?    ; LINE STATUS REGISTER
  178. MSR        DW    ?    ; MODEM STATUS REGISTER
  179. UART_SILO_LEN    DB    ?    ; Size of a silo chunk (1 for 8250)
  180. ;
  181. ; BUFFER POINTERS
  182. START_TDATA    DW    ?    ; INDEX TO FIRST CHARACTER IN X-MIT BUFFER
  183. END_TDATA    DW    ?    ; INDEX TO FIRST FREE SPACE IN X-MIT BUFFER
  184. START_RDATA    DW    ?    ; INDEX TO FIRST CHARACTER IN REC. BUFFER
  185. END_RDATA    DW    ?    ; INDEX TO FIRST FREE SPACE IN REC. BUFFER
  186. ; BUFFER COUNTS
  187. SIZE_TDATA    DW    ?    ; NUMBER OF CHARACTERS IN X-MIT BUFFER
  188. SIZE_RDATA    DW    ?    ; NUMBER OF CHARACTERS IN REC. BUFFER
  189. ; BUFFERS
  190. TBuff        DD    ?    ; Pointer to transmit buffer
  191. RBuff        DD    ?    ; Pointer to receive buffer
  192. SP_TAB        ENDS
  193.  
  194. ; SP_TAB EQUATES
  195. ; WE HAVE TO USE THESE BECAUSE OF PROBLEMS WITH STRUC
  196. EOVFLOW  EQU    ERROR_BLOCK    ; BUFFER OVERFLOWS
  197. EOVRUN